﻿using JinYuan.Models.HelperAttribute;
using Language;
using System.Windows.Forms;

namespace LargeSquareOne.ViewModel
{
    public static class FrmDataMonitorViewModel
    {
        public static void InitDiolameFrm(this FrmDataMonitor from)
        {
            from.dgvFeedingData.InitDgvFeedingData();
            from.dgvBlankingData.InitDgvBlankingData();
            from.dgvSteelShellData.InitDgvSteelShellData();
        }

        class DMoveInEntity
        {

            public string Remark { get; set; }
        }

        /// <summary>
        /// 指定类使用DataGridViewColumn
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="dataGridView"></param>
        public static void SetColumns<T>(this DataGridView dataGridView) where T : class, new()
        {
            T t = new T();
            var columnList = t.GetDataGridViewColumns();
            dataGridView.Columns.Clear();

            foreach (JinYuan.Models.HelperAttribute.DataGridViewColumn column in columnList)
            {
                // 构建语言键：窗体名_控件名_Column_列名
                //CommunicationEditForm_groupTable_Column_PlcNum
                string resourceKey = $"FrmDataMonitor_{dataGridView.Name}_{column.Name}Header";
                string translatedHeader = LanguageManager.GetString(resourceKey);
                // 获取翻译后的列标题
                dataGridView.SetColumnAutoWidth(translatedHeader, column.DataPropertyName, column.Name);
            }
        }
    }
}
